package org.hook.showcase.pattern.observer.impl;

import org.hook.showcase.pattern.observer.DisplayElement;
import org.hook.showcase.pattern.observer.Observer;
import org.hook.showcase.pattern.observer.Subject;

public class CurrentConditionDisplay implements Observer, DisplayElement {
	private Subject subject;
	private float temperature;
	private float humidity;

	public CurrentConditionDisplay(Subject subject) {
		this.subject = subject;
		this.subject.registerObserver(this); // for un-resisted from subject.
	}

	@Override
	public void display() {
		System.out.println("Current conditions:" + this.temperature + "F degrees and " + this.humidity + "% humidity.");
	}

	@Override
	public void update(float temperature, float humidity, float pressure) {
		this.temperature = temperature;
		this.humidity = humidity;
		this.display();
	}
}
